package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2023/01/14/23:35
 * @Description:wait（）方法
 */
public class WaitDemo {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t1=new Thread(()->{
            //
            System.out.println("线程1开始执行");
            try {
                synchronized (lock){
                    System.out.println("线程1调用wait方法");
                    lock.wait();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("线程1结束执行");
        },"线程1");
        t1.start();
    }
}
